#ifndef LOGGER_H
#define LOGGER_H

#include <QString>
#include <QFile>
#include <QTextStream>

class Logger {
public:
    enum LogLevel {
        Debug,
        Info,
        Warning,
        Error,
        Fatal
    };
    
    static Logger& instance();
    
    void log(LogLevel level, const QString &message);
    void debug(const QString &message) { log(Debug, message); }
    void info(const QString &message) { log(Info, message); }
    void warning(const QString &message) { log(Warning, message); }
    void error(const QString &message) { log(Error, message); }
    void fatal(const QString &message) { log(Fatal, message); }
    
    void setLogFile(const QString &filePath);
    void setLogLevel(LogLevel level) { m_logLevel = level; }
    
private:
    Logger();
    ~Logger();
    Logger(const Logger&) = delete;
    Logger& operator=(const Logger&) = delete;
    
    QFile m_logFile;
    QTextStream m_stream;
    LogLevel m_logLevel = Info;
    
    QString levelToString(LogLevel level);
};

#endif // LOGGER_H